#pragma once
#include "Bone.h"
#include "AnimationFrame.h"

#include <vector>
#include <map>
#include <memory>
#include <string>

namespace DYGraphics
{
	class _declspec(dllexport) Skeleton
	{
	public:
		Skeleton();
		void SetBone(int pIndex, Bone* pBone);
		Bone* GetBone(unsigned int idx) const;
		Bone* GetBone(std::string name) const;
		void AppyAnimFrame(AnimationFrame* frames);
		~Skeleton();
	public:
		bool IsBoneExist(std::string boneName) const 
		{ 
			return mBoneMap.count(boneName) > 0; 
		}

		// 创建骨骼数组
		void CreateBoneArray(int count) 
		{ 
			mBoneCount = count;
			mBoneArray = new Bone*[count]; 
		}

		// 获取骨骼的数量
		unsigned int GetBoneCount() const 
		{ 
			return mBoneCount; 
		}
	private:
		std::map<std::string, Bone*> mBoneMap;
		Bone* mRootBone;
		Bone** mBoneArray;
		int mBoneCount;
	};

	typedef std::shared_ptr<Skeleton> SkeletonPtr;
}